package com.agileai.pm.module.test.handler;

import java.util.Enumeration;
import java.util.List;

import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.controller.core.SimpleHandler;
import com.agileai.hotweb.renders.LocalRenderer;
import com.agileai.hotweb.renders.ViewRenderer;
import com.agileai.pm.module.test.service.TestProjectShortcomManage;

public class ShowBigPictureHandler extends SimpleHandler{
	public ShowBigPictureHandler(){
		super();
		this.serviceId = buildServiceId(TestProjectShortcomManage.class);
	}
	
    protected TestProjectShortcomManage getService() {
        return (TestProjectShortcomManage) this.lookupService(this.getServiceId());
    }
    
    public ViewRenderer prepareDisplay(DataParam param) {
		this.setAttributes(param);
		Enumeration<String> enumer = request.getAttributeNames();
		while(enumer.hasMoreElements()){
			String key = enumer.nextElement();
			Object value = request.getAttribute(key);
			this.setAttribute(key, value);
		}
		this.processPageAttributes(param);
		List<DataRow>imgList=this.getService().findBugImg(param);
		String imgSrc="";
		for(DataRow row:imgList){
			 imgSrc=row.getString("RES_LOCATION");
		}
		this.setAttribute("imgSrc", "http://localhost:"+getRequest().getServerPort()+imgSrc);
		request.setAttribute("imgList", imgList);
		return new LocalRenderer(getPage());
	}
}
